/**
 * Passenger class written for Bus Route Simulation. Can be reused with slight modifications to code for other assignments. 
 * No calculations done in this class, just string manipulation for output.
 * 
 *  Written by Jack Yuan 
 *  jly2104@columbia.edu
 *  
 *  COMSW3134 Assignment 1: Bus Route Simulation
 *  This code can be freely used, copied and manipulated except for COMSW3134
 **/
public class Passenger {
	/**
	 * Fields are mainly self explanatory, stop for what stop the passenger is at
	 * waitTime for how long the passenger has waited, timeAtStop is when the passenger
	 * arrived at the stop, busToTake is the time the bus that will pick them up is 
	 * deployed, stopGetOff is the stop they get off at and passNum is passenger number.
	 **/
	private int stop, waitTime, timeAtStop, busToTake, stopGetOff, passNum;
	
	/**
	 * Constructors:
	 * >>Default constructor sets all fields to 0
	 * >>Constructor that is used takes three ints, stop they are at, time they got there and passenger number
	 **/
	
	public Passenger(){
		this.stop = this.waitTime = this.timeAtStop = this.busToTake = this.stopGetOff = 0;
	}
	public Passenger(int stop, int timeAtStop, int passNum){
		this.stop = stop;
		this.waitTime = 0;
		this.timeAtStop = timeAtStop;
		this.passNum = passNum;
	}
	
	/**
	 * Accessors and Mutators for all fields.  
	 **/
	
	public int getBus(){return this.busToTake;}
	
	public int getStopOff(){return this.stopGetOff;}
	
	public int getStop(){return this.stop;}
	
	public int getWaitTime(){return this.waitTime;}
	
	public int getTimeAtStop(){return this.timeAtStop;}
	
	public void setStop(int stop){this.stop = stop;}
	
	public void setWaitTime(int waitTime){this.waitTime = waitTime;}
	
	public void setTimeAtStop(int timeAtStop){this.timeAtStop = timeAtStop;}
	
	public void setBustTake(int busToTake){this.busToTake = busToTake;}
	
	public void setStopOff(int stopGetOff){this.stopGetOff = stopGetOff;}
	
	/**
	 * toString method that is overwritten. No calculations done, just reformatting total number of minutes into a sensible time. 
	 **/
	
	public String toString(){
		String strTAS = "";
		if(timeAtStop/60 < 10){
			strTAS = "0"+(int)(timeAtStop/60);
		}
		else{
			strTAS =""+(int)(timeAtStop/60);
		}
		strTAS += ":";
		if(timeAtStop%60 <10){
			strTAS += "0"+timeAtStop%60;
		}
		else{
			strTAS += ""+timeAtStop%60;
		}
		String busdeploy = "";
		if(this.busToTake/60 < 10){
			if(this.busToTake % 60 < 10){
				busdeploy = "0"+this.busToTake/60 + ":0"+this.busToTake%60;
			}
			else{
				busdeploy = "0"+this.busToTake/60 + ":"+this.busToTake%60;
			}
		}
		else{
			if(this.busToTake % 60 < 10){
				busdeploy = ""+this.busToTake/60 + ":0"+this.busToTake%60;
			}
			else{
				busdeploy = ""+this.busToTake/60 + ":"+this.busToTake%60;
			}
		}
		int timePickedUp = this.busToTake + this.stop;
		String tpu = "";
		if(timePickedUp/60 < 10){
			if(timePickedUp % 60 < 10){
				tpu = "0"+timePickedUp/60 + ":0"+timePickedUp%60;
			}
			else{
				tpu = "0"+timePickedUp/60 + ":"+timePickedUp%60;
			}
		}
		else{
			if(timePickedUp % 60 < 10){
				tpu = ""+timePickedUp/60 + ":0"+timePickedUp%60;
			}
			else{
				tpu = ""+timePickedUp/60 + ":"+timePickedUp%60;
			}
		}
		String str = "Passenger "+this.passNum+" presents at stop "+this.stop+" at "+strTAS+" and wants to go to stop "+this.stopGetOff+".\n";
		str += "This passenger is picked up at "+tpu+" by the "+busdeploy+" bus, waiting "+this.waitTime+" mintue(s)";
		return str;
	}
	
}
